package com.eastfair.venueservice.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.boot.request.PageParams;
import com.eastfair.venueservice.dto.ServiceOrderDTO;
import com.eastfair.venueservice.entity.ServiceOrder;
import com.eastfair.venueservice.entity.WorkOrder;
import com.eastfair.venueservice.enumeration.ServiceOrderWorkOrderStatusEnum;
import com.eastfair.venueservice.vo.ServiceOrderVO;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 综合服务，主运 的订单服务.
 *
 * @author dqq
 * @date 2022 /11/10
 */
public interface VenueManageServiceOrderService {

    /**
     * 分页查询服务订单列表.
     *
     * @param pageParams the page params
     * @return the page
     */
    Page<ServiceOrderVO> listServiceOrderVOs(PageParams<ServiceOrderDTO> pageParams);

    /**
     * 订单编号获取服务订单VO.
     *
     * @param orderNumber the order number
     * @return the vo by order number
     */
    ServiceOrderVO getVOByOrderNumber(String orderNumber);

    /**
     * 保存服务订单.
     *
     * @param serviceOrderDTO the service order dto
     * @return the boolean
     */
    ServiceOrder saveServiceOrderForVenue(ServiceOrderDTO serviceOrderDTO);

    /**
     * 更新订单.
     *
     * @param serviceOrderDTO the service order dto
     * @return the boolean
     */
    ServiceOrder updateServiceOrder(ServiceOrderDTO serviceOrderDTO);

    /**
     * 提交订单.
     *
     * @param orderNumber order number
     * @return the boolean
     */
    boolean submitServiceOrder(String orderNumber);

    /**
     * 生成支付系统交易订单.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean saveTransactionOrder(String orderNumber);

    /**
     * 为支付订单补全字段.
     *
     * @param serviceOrder the service order
     * @return the service order dto
     */
    ServiceOrderDTO completeForTransactionOrder(ServiceOrder serviceOrder);

    /**
     * 取消订单.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean cancelServiceOrder(String orderNumber);

    /**
     * 超时未支付取消订单.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean cancelTimeoutNotPayServiceOrder(String orderNumber);

    /**
     * 订单编号更新订单为取消.
     *
     * @param orderNumber the order number
     * @return the service order
     */
    ServiceOrder updateOrderStatusCancel(String orderNumber);

    /**
     * 发起退款申请.
     *
     * @param serviceOrderDTO the service order
     * @return the boolean
     */
    boolean applyServiceOrderRefund(ServiceOrderDTO serviceOrderDTO);

    /**
     * 更新订单状态为已完成.
     *
     * @param serviceOrder the service order
     * @return the boolean
     */
    boolean updateOrderStatusComplete(ServiceOrder serviceOrder);

    /**
     * 更新订单状态为已完成.
     *
     * @param serviceOrder  the service order
     * @param workOrderList the work order list
     * @return the boolean
     */
    boolean updateOrderStatusComplete(ServiceOrder serviceOrder, List<WorkOrder> workOrderList);

    /**
     * 更新订单的工单状态为已派单.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean updateWorkOrderStatusHasDispatch(String orderNumber);

    /**
     * 更新派工状态未部分派工.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    @Transactional(rollbackFor = Exception.class)
    boolean updateWorkOrderStatusPartialDispatch(String orderNumber);

    /**
     * 更新订单状态为已接单.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean updateWorkOrderStatusHasReceive(String orderNumber);

    /**
     * 更新订单的工单状态为部分完成.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean updateWorkOrderStatusPartialComplete(String orderNumber);

    /**
     * 更新订单的工单状态为部分完成.
     *
     * @param serviceOrder the service order
     * @return the boolean
     */
    boolean updateWorkOrderStatusPartialComplete(ServiceOrder serviceOrder);

    /**
     * 更新订单的工单状态为已完成.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean updateWorkOrderStatusComplete(String orderNumber);

    /**
     * 更新订单的工单状态为已完成.
     *
     * @param serviceOrder  the service order
     * @param workOrderList the work order list
     * @return the boolean
     */
    boolean updateWorkOrderStatusComplete(ServiceOrder serviceOrder, List<WorkOrder> workOrderList);

    /**
     * 更新订单的工单状态为已取消.
     *
     * @param orderNumber the order number
     * @return the boolean
     */
    boolean updateWorkOrderStatusCancel(String orderNumber);

    /**
     * 更新订单的工单状态.
     *
     * @param orderNumber         the order number
     * @param workOrderStatusEnum the work order status enum
     * @return the boolean
     */
    boolean updateWorkOrderStatus(String orderNumber, ServiceOrderWorkOrderStatusEnum workOrderStatusEnum);

    /**
     * 支付订单.
     *
     * @param serviceOrderDTO the service order dto
     * @return the boolean
     */
    boolean payServiceOrder(ServiceOrderDTO serviceOrderDTO);

    /**
     * 申请开票发站内信
     *
     * @param serviceOrderDTO
     * @return
     */
    Boolean sendInnerMsg(ServiceOrderDTO serviceOrderDTO);
}